<script setup lang="ts">
import { useRouter } from 'vue-router'

const router = useRouter()

// 处理登出
const handleLogout = () => {
  localStorage.removeItem('token')
  router.push('/login')
}
</script>

<template>
  <div class="dashboard-container">
    <el-container style="height: 100%;">
      <el-aside width="200px">
        <div class="sidebar-header">
          <h3>酒店管理系统</h3>
        </div>
        <el-menu
          router
          default-active="/dashboard/hotels"
          class="sidebar-menu"
        >
          <el-menu-item index="/dashboard/hotels">
            <el-icon><Menu /></el-icon>
            <span>酒店管理</span>
          </el-menu-item>
          <el-menu-item index="/dashboard/orders">
            <el-icon><Document /></el-icon>
            <span>订单管理</span>
          </el-menu-item>
        </el-menu>
      </el-aside>
      <el-container>
        <el-header>
          <div class="header-right">
            <el-dropdown>
              <span class="el-dropdown-link">
                管理员
                <el-icon class="el-icon--right"><ArrowDown /></el-icon>
              </span>
              <template #dropdown>
                <el-dropdown-menu>
                  <el-dropdown-item @click="handleLogout">退出登录</el-dropdown-item>
                </el-dropdown-menu>
              </template>
            </el-dropdown>
          </div>
        </el-header>
        <el-main>
          <router-view />
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<style scoped>
.dashboard-container {
  height: 100vh;
}

.el-header {
  background-color: #fff;
  color: #333;
  line-height: 60px;
  border-bottom: 1px solid #e6e6e6;
  display: flex;
  justify-content: flex-end;
  padding: 0 20px;
}

.el-aside {
  background-color: #304156;
  color: #fff;
}

.sidebar-header {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid #1f2d3d;
}

.sidebar-header h3 {
  color: #fff;
  margin: 0;
  font-size: 16px;
}

.sidebar-menu {
  border-right: none;
  background-color: #304156;
}

:deep(.el-menu) {
  background-color: #304156;
}

:deep(.el-menu-item) {
  color: #bfcbd9;
}

:deep(.el-menu-item.is-active) {
  color: #409eff;
  background-color: #263445;
}

:deep(.el-menu-item:hover) {
  background-color: #263445;
}

.header-right {
  display: flex;
  align-items: center;
  height: 100%;
}

.el-dropdown-link {
  cursor: pointer;
  display: flex;
  align-items: center;
}
</style> 